home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group01b.txt
/
000077_icon-group-sender_Tue Jun 19 13:15:51 2001.msg
< prev
next >
Wrap
Internet Message Format
|
2002-01-03
|
3KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id f5JKDd612699
for icon-group-addresses; Tue, 19 Jun 2001 13:13:39 -0700 (MST)
Message-Id: <200106192013.f5JKDd612699@baskerville.CS.Arizona.EDU>
Date: Tue, 19 Jun 2001 08:24:44 -0700
From: Steve Wampler <swampler@noao.edu>
X-Accept-Language: en
To: deborah_fairwater@hotmail.com
CC: icon-group@cs.arizona.edu
Subject: Re: code needed!
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 1912
Chris.D.Tenaglia@jci.com wrote:
>
> #
> # file : padsent.icn
> # desc : add extra space to end of each sentence
> # use : padsent <infile >outfile
> #
> procedure main()
>
> while line := read() do
> {
> work := reverse(line)
> text := ""
> every i := 1 to *work do
> {
> text ||:= work[i]
> if (work[i] == " ") & (work[i+1] == ".") then text ||:= " "
> if (work[i] == " ") & (work[i+1] == "?") then text ||:= " "
> if (work[i] == " ") & (work[i+1] == "!") then text ||:= " "
Just to show an alternative formulation, the above three lines lines could
also be written as:
if work[i+:2] == (" ." | " ?" | " !") then text ||:= " "
But a full-up string scanning solution might be useful and wouldn't need
the string reversals:
# Danger, Will Robinson - untested code follows!
procedure main()
every write(repair(!&input))
end
procedure repair(line, sentenceEnders)
# setup default sentence-ending punctuation if 2nd argument is missing
/sentenceEnders := '.?!'
s := ""
line ? {
while s ||:= tab(upto(sentenceEnders)) || move(1) do {
# Don't add a second blank if it's already there
s ||:= =" " || (=" " | " ")
}
s ||:= tab(0)
}
return s
end
> }
> write(reverse(text))
> }
> end
>
>
> deborah_fairwater@h
> otmail.com To: icon-group@CS.Arizona.EDU
> cc:
> 06/16/01 03:53 PM Subject: code needed!
>
>
>
> Help - I need the icon code that will look at an input text file and
> replace single spaces between sentences with double spaces - can anyone
> help?
>
> Thank you.
--
Steve Wampler- SOLIS Project, National Solar Observatory
swampler@noao.edu